package com.loie.xcx.service.impl;


import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.loie.xcx.comm.JsonResult;
import com.loie.xcx.mapper.ApprovalformMapper;
import com.loie.xcx.model.bo.Approvalform;
import com.loie.xcx.model.bo.IwInstance;
import com.loie.xcx.service.ApprovalformService;
import com.loie.xcx.util.MailSend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2023-12-01
 */
@Service
public class ApprovalformServiceImpl extends ServiceImpl<ApprovalformMapper, Approvalform> implements ApprovalformService {

    @Autowired
    ApprovalformMapper approvalformMapper;
    @Autowired
    MailSend mailSend;
    @Override
    public JsonResult<JSONObject> sendmiallist() {
        QueryWrapper<Approvalform> wrapper = new QueryWrapper<>();
//        String recordid = "4E56FBF4-F0B9-422E-A129-C0FB130B184B";
//        String modulename = "赊销额度申请";
        wrapper.select(" * ");
        wrapper.eq("is_send", 0)

                .isNotNull("recordid");
        List<Approvalform> approvalformList = approvalformMapper.selectList(wrapper);
        JsonResult<JSONObject> mailist = mailSend.sendEmail(approvalformList);
//        Integer count=approvalformMapper.selectCount(wrapper).intValue();
//        //List<String> mailist=new ArrayList<>();
//        if (count>0) {
//            List<Approvalform> approvalformList = approvalformMapper.selectList(wrapper);
//            JsonResult<JSONObject> mailist = mailSend.sendEmail(approvalformList);
//        }
//        else{
//            mailist.add("无发送记录");
//        }


        return mailist;
    }
    // public

}
